import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Cerca here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Cerca extends Obstaculos
{
    private int Speed = 2;
    
    /**
     * Act - do whatever the Cerca wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
         mueve();
         checaMovimiento();
    }  
    
    public void mueve(){
      setLocation (this.getX(), this.getY() - Speed);
    }
    
    public void checaMovimiento(){
    
       if(getY() > getWorld().getHeight()-20 || getY() < 10){
          Speed += 4;
          Speed = -Speed;
           }
           
        }
}